﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting.Server.Features;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MicroService.APIResource.Controllers
{
    //[Authorize(Policy = "ClientServicePolicy")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ClientServiceController : ControllerBase
    {
        private readonly ILogger<ClientServiceController> _logger;

        private IConfiguration Configuration;

        public ClientServiceController(ILogger<ClientServiceController> logger, IConfiguration Configuration)
        {
            _logger = logger;
            //ServerAddress = serAddFur.Addresses.FirstOrDefault();
            this.Configuration = Configuration;

            //命令行参数          
            string healthUrl = $"http://{Configuration["ip"]}:{Configuration["port"]}{Configuration["Consul:CheckUrl"]}";
            Console.WriteLine($"ServerInfo: {healthUrl}");
        }
        [HttpGet]
        public IEnumerable<string> GetData()
        {
            //命令行参数          
            string healthUrl = $"http://{Configuration["ip"]}:{Configuration["port"]}{Configuration["Consul:CheckUrl"]}";
            return new string[] { "ClientService-value1", healthUrl, DateTime.Now.ToLongTimeString() };
        }
    }
}
